package Infinite::Sequence::Product;
use Exporter qw{import};

our @EXPORT_OK = qw{PRODUCT Product};

sub Product { PRODUCT(@_) }
sub PRODUCT {
	my $sequence = pop;
    my @range = @_;
    
    die q{Infinite product works only in positive range} if $range[0] < 0;

    Infinite::Sequence::take( $range[0] => $sequence ) if 0 < $range[0];
    
    my @elements = Infinite::Sequence::take( scalar( @range ), $sequence );
    
    my $product = 1;
    $product *= $_ for @elements;
    $product
}

1